﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:Navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight"
    xmlns:Common="clr-namespace:FU.Capstones.IMS.Web.Common;assembly=FU.Capstones.IMS.Web.Common" 
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls" 
    xmlns:TControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Data" 
    Navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.EmployeeListViewModel"
	x:Class="FU.Capstones.IMS.Web.Silverlight.Views.EmployeeList">

    <UserControl.Resources>
        <Common:DataContextProxy x:Key="DataContextProxy"/>
    </UserControl.Resources>
    
    <telerik:RadBusyIndicator 
        BusyContent="Đang kết nối tới máy chủ..." 
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}">
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
            </Grid.RowDefinitions>
        
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <!--Title-->
            <Grid Grid.ColumnSpan="3">

                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>

                <TextBlock 
                    x:Name="lblTitle" 
                    Style="{StaticResource TextBlockTitlePageStyle}"                   
                    Text="{StaticResource EmployeeListPageTitle}"/>
            </Grid>

            <!--Search Bar-->
            <Controls:EmployeeSearchControl
                Grid.Row="2" Grid.Column="1"
                Margin="5,2"
                />
            <!--Grid-->
            <telerikGrid:RadGridView
                x:Name="GridView"
                Grid.Row="4" Grid.Column="1"
                telerik:StyleManager.Theme="Office_Black"
                Style="{StaticResource RadGridViewNormal}"
                ItemsSource="{Binding Path=EmployeeCollection, Mode=TwoWay}"                
                >
            
                <telerikGrid:RadGridView.Columns>

                    <telerikGrid:GridViewColumn
                        Header="{StaticResource UsernameLabelText}"
                        Width="120" HeaderTextAlignment="Center">
                        <telerikGrid:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <HyperlinkButton 
                                    Content="{Binding Path=Username}"                                        
                                    Command="{Binding Path=DataSource.EditCommand, 
                                                                        Source={StaticResource DataContextProxy}}"
                                    CommandParameter="{Binding Path=EmployeeID}"
                                />
                            </DataTemplate>
                        </telerikGrid:GridViewColumn.CellTemplate>
                    </telerikGrid:GridViewColumn >

                    <telerikGrid:GridViewDataColumn 
                        Header="{StaticResource EmployeeLabelText}"
                        Width="130" HeaderTextAlignment="Center"
                        DataMemberBinding="{Binding Path=FullName}"
                    />

                    <telerikGrid:GridViewDataColumn 
                        Header="{StaticResource RoleLabelText}"
                        Width="100" HeaderTextAlignment="Center"
                        DataMemberBinding="{Binding Path=Role.RoleName}"
                    />

                    <telerikGrid:GridViewDataColumn 
                        Header="{StaticResource EmploymentTypeLabelText}"
                        Width="120" HeaderTextAlignment="Center"
                        DataMemberBinding="{Binding Path=EmploymentType.EmploymentTypeName}"
                    />

                    <telerikGrid:GridViewDataColumn 
                        Header="{StaticResource AddressLabelText}"
                        Width="150" HeaderTextAlignment="Center"
                        DataMemberBinding="{Binding Path=Address}"
                    />
                
                    <telerikGrid:GridViewColumn Width="70">
                            <telerikGrid:GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <HyperlinkButton 
                                            Content="{StaticResource DeleteButtonText}"    
                                            Command="{Binding Path=DataSource.DeleteCommand, Source={StaticResource DataContextProxy}}"
                                            CommandParameter="{Binding Path=EmployeeID}"
                                            IsEnabled="{Binding Path=DataSource.CanEditOrAdd, Source={StaticResource DataContextProxy}}"
                                            Visibility="{Binding Path=IsDelete, Converter={StaticResource InverseBoolToVisibilityConverter}}"
                                        />
                                    <TextBlock 
								            Text="{StaticResource DeletedLabelText}"
                                            Style="{StaticResource TextBlockNormalStyle}"                                        
                                            Visibility="{Binding Path=IsDelete, Converter={StaticResource BoolToVisibilityConverter}}"
                                        />
                                    </Grid>
                                </DataTemplate>
                            </telerikGrid:GridViewColumn.CellTemplate>
                        </telerikGrid:GridViewColumn>
                    </telerikGrid:RadGridView.Columns>
            </telerikGrid:RadGridView>

            <!--Button-->
            <Grid Grid.Row="5" Grid.Column="1">
                <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                    <Controls:AddButtonControl                         
                        Visibility ="{Binding Path=CanAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                        />
                    <Controls:ShowAllCheckBoxControl  
                        Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"                  
                        />
                </StackPanel>

                <TControls:RadDataPager
                    x:Name="DataPager"
                    Source="{Binding Path=EmployeeCollection, Mode=TwoWay}"
                    Style="{StaticResource DataPagerNormalStyle}"
                    />
            </Grid>

        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
